<?php
/**
 * common model file Created by PhpStorm.
 * User: yang
 * Date: 2020/06/23
 */

namespace Common\Model;

class ForumComment extends Base
{
    protected $table = 'forum_comment';
    protected $guarded = [];
    
    //public $timestamps = false;

    //一对一关联用户
    public function get_user()
    {
        return $this->hasOne(User::class, 'id', 'user_id')
            ->select('id', 'name', 'rank', 'head_img', 'sign');
    }
    //一对一关联点赞
    public function get_comm_zan()
    {
        return $this->hasMany(ForumZan::class, 'comment_id', 'id')
            ->where('type', 2)
            ->select(['id', 'comment_id', 'user_id']);
    }
}